<?php

namespace app\api\controller\v1;
use app\api\controller\Base;
use think\Controller;
use think\Db;
use app\common\model\TestModel as TestModel;

class Test extends Base
{
	public function index(){
		$db = new TestModel();
		$sli = $this->request->param('sli');
		$test_name = $db->where('test_sli','=',$sli)->value('test_name');
		if($test_name){
			//return dump($page);
			//$page = $this->request->param('page');
			//$res =db($test_name)->paginate(20,false,['page'=>$page]);
			$list = $db->where('test_sli','=',$sli)->field('test_name,update_time,test_radio,test_judge,test_multi,radio_score,judge_score,multi_score')->find();
			$res =db($test_name)->select();
			return json(['code'=>1,'msg'=>'ok','title'=>$list,'data'=>$res],200);
		}else{
   			return json(['code'=>0,'msg'=>'授权码错误，请联系管理员！'],400);
		}
	}
	public function read(){
		$db = new TestModel();
		$sli = $this->request->param('sli');
		$list = $db->where('test_sli','=',$sli)->field('test_name,update_time')->find();
		if($list){
			return json(['code'=>1,'msg'=>'ok','data'=>$list],200);
		}else{
   			return json(['code'=>0,'msg'=>'授权码错误，请联系管理员！'],400);
		}
	}

}